<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <!--Head -->
    <h:head>
        <title>Karangoos Car</title>         
        <link rel="stylesheet" href="resources/css/estilos.css"/>
    </h:head>

    <!--Body -->
    <h:body>        
        <p:growl id="messages" autoUpdate="true" showDetail="true"></p:growl>
        <p:ajaxStatus onstart="PF('statusDialog').show();" onsuccess="PF('statusDialog').hide();"/>          
        <p:dialog modal="true" widgetVar="statusDialog" header="Aguarde..."   
                  draggable="false" closable="false">  
            <div align="center"> 
                <p:graphicImage value="resources/img/loader.gif" />  
            </div>
        </p:dialog> 

        <!--Form Principal -->
        <h:form id="formPrincipal" >
            <div id="divLogo" align="center">                
                <p:graphicImage value="resources/img/logoKarangoos.png" width="793" height="236"/>

            </div>
            <!--Barra de Menu -->
            <div align="left">
                <p:toolbar style="font-size: small">
                    <p:toolbarGroup align="left">
                        <p:menuButton  value="Perfil">
                            <p:menuitem id="alterarCadastro" disabled="#{!beanLogin.logado}"  value="Alterar"
                                        style="font-size: small"
                                        onclick="diagAlterarUsuario.show();">
                            </p:menuitem>
                            <p:menuitem id="deletarPerifl" disabled="#{!beanLogin.logado}" value="Deletar" 
                                        style="font-size: small"
                                        onclick="diagExcluirUsuario.show();">
                            </p:menuitem>                                                          
                        </p:menuButton>
                        <p:menuButton  value="Transações" >
                            <p:menuitem id="transacoesPendentes" disabled="#{!beanLogin.logado}" value="Transações Pendentes" 
                                        style="font-size: small"
                                        onclick="diagTransacoes.show();">
                            </p:menuitem>
                            <p:menuitem id="historicoTransacoes" disabled="#{!beanLogin.logado}" value="Histórico"
                                        style="font-size: small"
                                        onclick="diagHistoricoTransacoes.show();">
                            </p:menuitem>
                        </p:menuButton>
                        <p:menuButton  value="Veículos"  >
                            <p:menuitem id="incluirVeiculos" disabled="#{!beanLogin.logado}" value="Incluir"
                                        style="font-size: small"
                                        onclick="diagInserirImagem.show();" 
                                        actionListener="#{beanVeiculo.resetVeiculos()}"
                                        update=":formIncluirVeiculo:diagIncluirVeiculo">
                            </p:menuitem>
                            <p:menuitem id="meusVeiculos" style="font-size: small"                                        
                                        ajax="false"
                                        disabled="#{!beanLogin.logado}" 
                                        value="Meus Veiculos"                                        
                                        update=":formVeiculos:dataGridVeiculos"
                                        actionListener="#{beanVeiculo.meusVeiculos(beanLogin.usuarioLocal.pkId)}" >
                            </p:menuitem>
                        </p:menuButton>  
                        <p:menuButton  value="Sobre">
                            <p:menuitem id="notas" style="font-size: small"                                                                                                                 
                                        value="Notas"                                                                                
                                        onclick="diagSobre.show();">
                            </p:menuitem>

                        </p:menuButton>
                        <p:spacer width="10px"></p:spacer>
                        <p:inputText value="#{beanVeiculo.search}"/>
                        <p:commandButton value="Buscar"
                                         ajax="false"
                                         update=":formVeiculos:dataGridVeiculos"
                                         actionListener="#{beanVeiculo.search()}"/>
                    </p:toolbarGroup>


                    <p:toolbarGroup align="right">
                        <h:outputText id="labelUsername" value="Username" style="margin-right: 5px;">
                        </h:outputText>
                        <p:inputText id="inputLoginUser" 
                                     size="8" 
                                     value="#{beanLogin.username}" 
                                     disabled="#{beanLogin.logado}"
                                     style="margin-right: 20px"/>
                        <h:outputText id="labelPassword" value="Password" style="margin-right: 5px">                            
                        </h:outputText>
                        <p:password id="inputLoginPassword" 
                                    size="8" 
                                    value="#{beanLogin.password}" 
                                    disabled="#{beanLogin.logado}"
                                    style="margin-right: 20px">
                        </p:password>
                        <p:commandButton value="Entrar"
                                         ajax="false"
                                         title="Entrar"
                                         action="#{beanLogin.loginUser()}"                                         
                                         update="formPrincipal"
                                         disabled="#{beanLogin.logado}">
                        </p:commandButton>
                        <p:commandButton value="Cadastrar" 
                                         title="Cadastrar"
                                         disabled="#{beanLogin.logado}"
                                         update="formPrincipal"
                                         oncomplete="diagNovoUsuario.show();">
                        </p:commandButton>
                        <p:commandButton value="Sair" 
                                         title="Sair"
                                         ajax="false"
                                         update="formPrincipal"                                         
                                         actionListener="#{beanLogin.logoff()}"
                                         disabled="#{!beanLogin.logado}">
                        </p:commandButton>  
                        <p:commandButton id="buttonHome" icon="icon-home" 
                                         ajax="false"
                                         title="Inicio"
                                         actionListener="#{beanVeiculo.resetSearch()}"
                                         update=":formPrincipal"/>
                    </p:toolbarGroup>
                </p:toolbar>
            </div>   
        </h:form><br></br> 
        <!--Diag Sobre-->
        <h:form>
            <p:dialog hideEffect="bounce" widgetVar="diagSobre"  header="Nota Util"> 
                <h:outputText value="Este site foi desenvolvido para um trabalho de faculdade e, por conta do prazo"></h:outputText><br></br>
                <h:outputText value="curto para entrega, alguns bugs não puderam ser consertados em tempo. Algumas "></h:outputText><br></br>
                <h:outputText value="melhorias também não puderam ser feitas, ainda. Sugestões, elogios ou críticas "></h:outputText><br></br>
                <h:outputText value="podem ser enviadas para o email rafael.barbiero@hotmail.com e serão bem vindas."></h:outputText><br></br><br></br>
                <h:outputText style="font-weight: bold" value="Obrigado pela compreensão!"></h:outputText>                                            
            </p:dialog>
        </h:form>
        <!--Form Novo Usuario -->
        <h:form id="formNovoUsuario">           
            <p:dialog header="Novo Cadastro" widgetVar="diagNovoUsuario">
                <h:panelGrid id="gridInserirUser" columns="2" style="alignment-adjust: central">

                    <h:outputText value="Login"></h:outputText>
                    <h:inputText id="inputUser" value="#{beanLogin.usuarioLocal.login}" maxlength="8" required=" true"></h:inputText>                   

                    <h:outputText value="Senha"></h:outputText>
                    <h:inputText value="#{beanLogin.usuarioLocal.senha}" maxlength="8" required=" true "></h:inputText>                    

                    <h:outputText value="Apelido"></h:outputText>
                    <h:inputText value="#{beanLogin.usuarioLocal.apelido}" maxlength="20" required=" true "></h:inputText>

                    <h:outputText value="Email"></h:outputText>
                    <h:inputText value="#{beanLogin.usuarioLocal.email}" maxlength="45" required=" true "></h:inputText>

                </h:panelGrid>
                <p:separator></p:separator>
                <div align="center">                    
                    <p:commandButton value="Salvar"                                                                          
                                     actionListener="#{beanLogin.inserirUsuario()}">
                    </p:commandButton>
                    <p:commandButton ajax="false"
                                     value="Cancelar"
                                     update=":formPrincipal"
                                     onclick="PF('diagNovoUsuario').hide();">

                    </p:commandButton>
                </div>
            </p:dialog>            
        </h:form>  

        <!--Form Alterar Usuario -->
        <h:form id="formAlterarUsuario">
            <p:dialog header="Alteração de Dados" widgetVar="diagAlterarUsuario">
                <div align="center">
                    <h:outputText value="Clique no campo para alterar!"></h:outputText><br></br>
                    <p:separator></p:separator>
                    <h:panelGrid columns="2">
                        <h:outputText value="Id: " style="text-align: right; font-size: large"></h:outputText>
                        <h:outputText value="#{beanLogin.usuarioLocal.pkId}" style="text-align: right;font-size: large"></h:outputText>
                        <h:outputText value="Login: " style="text-align: right; font-size: large"></h:outputText>
                        <p:inplace editor="true">
                            <p:inputText value="#{beanLogin.usuarioLocal.login}" style="font-size: small"></p:inputText>
                        </p:inplace>
                        <h:outputText value="Email: " style="text-align: right; font-size: large"></h:outputText>
                        <p:inplace editor="true" >
                            <p:inputText value="#{beanLogin.usuarioLocal.email}" style="font-size: small" ></p:inputText>
                        </p:inplace>
                        <h:outputText value="Apelido: " style="text-align: right; font-size: large"></h:outputText>
                        <p:inplace editor="true" >
                            <p:inputText value="#{beanLogin.usuarioLocal.apelido}" style="font-size: small" ></p:inputText>
                        </p:inplace>
                    </h:panelGrid>
                </div>
                <p:separator></p:separator>
                <div align="center">
                    <p:commandButton ajax="false" 
                                     value="Alterar" 
                                     update="formPrincipal"
                                     action="#{beanLogin.logoff()}"
                                     actionListener="#{beanLogin.atualizarUsuario()}">
                    </p:commandButton>
                    <p:commandButton ajax="false" 
                                     value="Cancelar" 
                                     action="index">

                    </p:commandButton>
                </div>
            </p:dialog>
        </h:form>

        <!--Form Excluir Usuario -->
        <h:form id="formExcluirUsuario">
            <p:dialog header="Excluir Dados" widgetVar="diagExcluirUsuario">
                <h:panelGrid columns="2" style="alignment-adjust: central">
                    <h:outputText value="Login"></h:outputText>
                    <h:outputText value="#{beanLogin.usuarioLocal.login}"></h:outputText>
                    <h:outputText value="Apelido"></h:outputText>
                    <h:outputText value="#{beanLogin.usuarioLocal.apelido}"></h:outputText>
                    <h:outputText value="Email"></h:outputText>
                    <h:outputText value="#{beanLogin.usuarioLocal.email}"></h:outputText>
                </h:panelGrid>
                <p:separator></p:separator>
                <div align="center">
                    <p:commandButton ajax="false" 
                                     value="Excluir" 
                                     update="formPrincipal"
                                     action="#{beanLogin.logoff()}"
                                     actionListener="#{beanLogin.deletarUsuario()}">                        
                    </p:commandButton>                    
                    <p:commandButton ajax="false"
                                     value="Cancelar"
                                     update="formPrincipal"
                                     action="index">                    
                    </p:commandButton>
                </div>
            </p:dialog>
        </h:form>      

        <!--Form Alterar Veiculos -->
        <h:form id="formAlterarVeiculo" prependId="true" >
            <p:outputPanel id="outputAlterarVeiculo">  
                <p:dialog id="diagAlterarVeiculo" header="Alterar Veículos" widgetVar="diagAlterarVeiculo">                    
                    <div align="center">       
                        <h:panelGrid columns="2" style="alignment-adjust: central">                       

                            <h:outputText value="Id"></h:outputText>
                            <h:outputText value="#{beanVeiculo.veiculo.pkVeiculos}"/>

                            <h:outputText value="Nome"></h:outputText>
                            <p:inputText value="#{beanVeiculo.veiculo.nome}"/>

                            <h:outputText value="Ano"></h:outputText>                    
                            <p:inputText value="#{beanVeiculo.veiculo.anoFabricacao}"/>

                            <h:outputText value="Combustivel"></h:outputText>
                            <p:inputText value="#{beanVeiculo.veiculo.combustivel}"/>

                            <h:outputText value="Marca"></h:outputText>
                            <p:inputText value="#{beanVeiculo.veiculo.marca}"/>

                            <h:outputText value="Preço"></h:outputText>
                            <p:inputText value="#{beanVeiculo.veiculo.valor}"/>
                        </h:panelGrid>
                    </div>

                    <div align="center">
                        <p:separator></p:separator>
                        <p:commandButton ajax="false" 
                                         value="Alterar" 
                                         update="formPrincipal"                                     
                                         actionListener="#{beanVeiculo.alterarVeiculos(actionEvent, beanLogin.usuarioLocal, beanVeiculo.veiculo)}">
                        </p:commandButton>
                        <p:commandButton ajax="false"
                                         value="Cancelar"
                                         update="formPrincipal"
                                         action="index">                    
                        </p:commandButton>                       
                    </div>

                </p:dialog>                    
            </p:outputPanel>           
        </h:form>       

        <!--Form Veiculos -->        
        <h:form id="formVeiculos" >
            <div align="center" >
                <p:outputPanel autoUpdate="true">
                    <p:dataGrid id="dataGridVeiculos" var="carro" value="#{beanVeiculo.getListaVeiculos()}" 
                                columns="3"
                                emptyMessage="Nenhum veículo cadastrado."                               
                                rows="12" paginator="true"  
                                paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink}"  
                                rowsPerPageTemplate="3,9,12,15">  
                        <p:panel header="#{carro.nome}" style="text-align:center;"  >                            
                            <p:graphicImage value="resources/imgCarros/thumbs/#{carro.pkVeiculos}thumbs.jpeg"/>                            
                            <div align="center"> 
                                <h:panelGrid columns="2" style="width:50%">                                  
                                    <h:outputText value="Modelo:" style="text-align: right; text-decoration-color: #{carro.cor} " />
                                    <h:outputText value="#{carro.nome}" style="text-align: center" />
                                    <h:outputText value="Marca:" style="text-align: right; color: #646582"  />
                                    <h:outputText value="#{carro.marca}" style="text-align: center" />
                                    <h:outputText value="Ano:" style="text-align: right; color: #646582" />
                                    <h:outputText value="#{carro.anoFabricacao}" style="text-align: center" />
                                </h:panelGrid> 
                            </div>                                             
                            <div align="center">
                                <p:commandButton update=":formDiagVeiculos:outputDetalhesVeiculo" 
                                                 icon="icon-zoom"
                                                 oncomplete="PF('diagDetalhesVeiculo').show()" 
                                                 title="Detalhes do Veiculo">                                                                  
                                    <f:setPropertyActionListener value="#{carro}" target="#{beanVeiculo.veiculo}" />                                  
                                </p:commandButton>
                                <p:commandButton update=":formAlterarVeiculo:outputAlterarVeiculo" 
                                                 icon="icon-editar"
                                                 oncomplete="PF('diagAlterarVeiculo').show()" 
                                                 title="Detalhes do Veiculo"                                  
                                                 disabled="#{beanVeiculo.validateEditarExcluirf(beanLogin.usuarioLocal, carro.usuarios.pkId, beanLogin.logado)}">
                                    <f:setPropertyActionListener value="#{carro}" target="#{beanVeiculo.veiculo}" />  
                                </p:commandButton>  
                                <p:commandButton icon="icon-delete"   
                                                 update="dataGridVeiculos"
                                                 actionListener="#{beanVeiculo.excluirVeiculos(beanLogin.usuarioLocal,carro)}"
                                                 disabled="#{beanVeiculo.validateEditarExcluirf(beanLogin.usuarioLocal, carro.usuarios.pkId, beanLogin.logado)}">
                                    <f:setPropertyActionListener value="#{carro}" target="#{beanVeiculo.veiculo}" />                                
                                    <p:confirm header="Confirmar Exclusão" message="Deseja excluir o veiculo?" icon="ui-icon-alert" /> 
                                </p:commandButton>
                                <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                                    <div align="center">
                                        <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
                                        <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                                    </div>
                                </p:confirmDialog> 
                            </div>                                                                            
                        </p:panel>                     
                    </p:dataGrid>  
                </p:outputPanel>                 
            </div>            
        </h:form>         

        <!-- Form Incluir Veiculo -->
        <h:form id="formIncluirVeiculo" >
            <p:dialog id="diagIncluirVeiculo" header="Incluir Veículos" widgetVar="diagIncluirVeiculos" onShow="PF('diagInserirImagem').hide();" position="top" >
                <p:graphicImage id="imagemCarro" cache="false" value="#{beanUpload.imagem}" height="300" style="margin: 0 auto;"/>
                <div align="center">                              
                    <h:panelGrid columns="2" style="alignment-adjust: central">

                        <h:outputText value="Nome"/>
                        <p:inputText value="#{beanVeiculo.veiculo.nome}"/>

                        <h:outputLabel value="Ano"/>
                        <p:inputText value="#{beanVeiculo.veiculo.anoFabricacao}"/>

                        <h:outputText value="Combustivel"/>
                        <p:inputText value="#{beanVeiculo.veiculo.combustivel}"/>

                        <h:outputText value="Marca"/>
                        <p:inputText value="#{beanVeiculo.veiculo.marca}"/>                       

                        <h:outputLabel value="Valor"/>
                        <p:inputText value="#{beanVeiculo.veiculo.valor}"/>                                                
                    </h:panelGrid>                        
                </div>
                <div align="center">
                    <p:separator></p:separator>
                    <p:commandButton value="Salvar"                                                                                                          
                                     actionListener="#{beanVeiculo.inserirVeiculos(actionEvent, beanLogin.usuarioLocal, beanUpload.fileUploadEvent)}">                        
                    </p:commandButton>                    
                    <p:commandButton ajax="false"
                                     value="Cancelar"                                              
                                     oncomplete="PF('diagIncluirVeiculos').hide();">                    
                    </p:commandButton>                       
                </div> 
            </p:dialog>                        
        </h:form>

        <!--Form Inserir Imagem -->
        <h:form id="formInserirImagem" enctype="multipart/form-data">
            <p:dialog header="Upload de Imagem" 
                      widgetVar="diagInserirImagem" 
                      hideEffect="fade"
                      onHide="incluirVeiculo"
                      dynamic="true">
                <p:fileUpload fileUploadListener="#{beanUpload.doUpload}"                            
                              auto="false"
                              fileLimit="1"
                              fileLimitMessage="Desculpe, mas é permitido carregar apenas uma imagem!"                              
                              mode="advanced"
                              update=":formIncluirVeiculo:diagIncluirVeiculo"
                              cancelLabel="Cancelar"
                              uploadLabel="Carregar"   
                              oncomplete="PF('diagIncluirVeiculos').show();"
                              label="Procurar..."/>               
            </p:dialog>
        </h:form>       

        <!--Form Diag Veiculos -->
        <h:form id="formDiagVeiculos">
            <p:dialog header="Detalhes do Veiculo" maximizable="true" widgetVar="diagDetalhesVeiculo" position="top" closeOnEscape="true" >  
                <p:outputPanel id="outputDetalhesVeiculo" >
                    <p:outputPanel autoUpdate="true" >
                        <p:panel id="panelCurtir" rendered="#{beanLogin.logado}" style="font-size: smaller;" >
                            <div align="right">
                                <p:outputLabel id="outputRating" 
                                               style="color: cornflowerblue"
                                               value="#{beanVeiculo.rating}"/>
                                <p:spacer height="10px"/>
                                <p:commandButton value="Curtir"                                                 
                                                 disabled="#{beanRating.validateCurtir(beanLogin.usuarioLocal.pkId, beanVeiculo.veiculo.pkVeiculos)}"
                                                 actionListener="#{beanRating.inserirRating(beanLogin.usuarioLocal, beanVeiculo.veiculo)}">
                                </p:commandButton>
                            </div>                            
                        </p:panel>
                    </p:outputPanel>

                    <h:panelGrid columns="2">                        
                        <h:panelGrid columns="1">
                            <!--Painel Detalhes -->    
                            <p:panel header="Detalhes" >                            
                                <h:panelGrid columns="2">
                                    <h:panelGrid columns="1" style="text-align: right">
                                        <h:outputLabel  value="Nome: " style="color: cornflowerblue; text-align-last: center"/>  
                                        <h:outputLabel  value="Marca: " style="color: cornflowerblue"/>  
                                        <h:outputLabel  value="Ano: " style="color: cornflowerblue"/>  
                                        <h:outputLabel  value="Combustível: " style="color: cornflowerblue"/>  
                                        <h:outputLabel  value="Valor: " style="color: cornflowerblue"/>  
                                        <h:outputLabel  value="Proprietário: " style="color: cornflowerblue"/>  
                                    </h:panelGrid>
                                    <h:panelGrid columns="1" style="color: cadetblue">
                                        <h:outputText value="#{beanVeiculo.veiculo.nome}"/>  
                                        <h:outputText value="#{beanVeiculo.veiculo.marca}"/> 
                                        <h:outputText value="#{beanVeiculo.veiculo.anoFabricacao}"/>  
                                        <h:outputText value="#{beanVeiculo.veiculo.combustivel}" />  
                                        <h:outputText value="R$ #{beanVeiculo.veiculo.valor}"/>
                                        <h:outputText value="#{beanVeiculo.veiculo.usuarios.apelido}"/>
                                    </h:panelGrid>
                                </h:panelGrid>
                                <div align="center">
                                    <p:panel rendered="#{beanLogin.logado}">
                                        <p:commandButton disabled="#{beanVeiculo.validateComprar(beanLogin.usuarioLocal, beanVeiculo.veiculo.usuarios.pkId, beanLogin.logado,beanVeiculo.veiculo.pkVeiculos)}"
                                                         actionListener="#{beanTransacoes.inserirTransacoes(beanVeiculo.veiculo, beanLogin.usuarioLocal)}"                                         
                                                         oncomplete="PF('diagDetalhesVeiculo').hide();"
                                                         update=":formPrincipal"
                                                         value="Comprar" >
                                            <p:confirm header="Confirmar Compra" message="Deseja comprar este veículo?" icon="ui-icon-alert" /> 
                                        </p:commandButton>
                                        <p:confirmDialog id="diagConfirmaCompra" global="true" showEffect="fade" hideEffect="explode" closable="false" >  
                                            <div align="center">
                                                <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
                                                <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                                            </div>
                                        </p:confirmDialog>
                                    </p:panel>

                                </div>
                            </p:panel>
                            <p:panel header="Comentarios">
                                <p:dataList var="coments" 
                                            paginator="true"
                                            rows="3"
                                            style="text-align: center; font-size: smaller"
                                            emptyMessage="Nenhum comentário!"
                                            value="#{beanComentarios.getComentarios(beanVeiculo.veiculo.pkVeiculos)}" 
                                            itemType="circle" >
                                    #{coments.usuarios.apelido}: #{coments.comentario}!
                                </p:dataList>
                                <div align="center">
                                    <p:panel rendered="#{beanLogin.logado}" style="font-size: smaller" >
                                        <p:commandButton value="Comentar" 
                                                         disabled="#{beanVeiculo.validateCurtirComentar(beanLogin.usuarioLocal, beanVeiculo.veiculo.usuarios.pkId, beanLogin.logado)}"
                                                         onclick="PF('diagInserirComentarios').show();"
                                                         actionListener="#{beanComentarios.resetComentarios()}">
                                        </p:commandButton>
                                    </p:panel>
                                </div>
                            </p:panel> <!--Painel Comentarios -->                                             
                        </h:panelGrid>
                        <p:panel header="#{beanVeiculo.veiculo.nome}">
                            <p:graphicImage id="imagemCarro" 
                                            value="resources/imgCarros/idVeiculo/#{beanVeiculo.veiculo.pkVeiculos}.jpeg"/>
                        </p:panel> <!--Painel Imagem -->                      
                    </h:panelGrid>

                </p:outputPanel>  
            </p:dialog>
        </h:form>       

        <!--Form Historico Transacoes -->
        <h:form id="formHistoricoTransacoes" >
            <div align="center">
                <p:dialog header="Historico de Transações" widgetVar="diagHistoricoTransacoes" >
                    <p:panel header="Historico de Compras" style="height: auto; width: auto" >  
                        <p:dataTable id="dataHistoricoTransacoesCompras"                                      
                                     scrollable="false"
                                     resizableColumns="false"
                                     paginator="true" 
                                     paginatorAlwaysVisible="false"                                      
                                     var="historicoCompras" 
                                     value="#{beanHistorico.getHistoricoCompras(beanLogin.usuarioLocal.pkId)}">
                            <p:column headerText="Comprador" style="text-align: center">
                                <h:outputText value="#{historicoCompras.comprador}"/>  
                            </p:column>
                            <p:column headerText="Vendedor" style="text-align: center">
                                <h:outputText value="#{historicoCompras.vendedor}"/>
                            </p:column>
                            <p:column headerText="Veiculo" style="text-align: center">
                                <h:outputText value="#{historicoCompras.veiculo}"/>
                            </p:column>
                            <p:column headerText="Valor" style="text-align: center">
                                <h:outputText value="#{historicoCompras.valor}"/>
                            </p:column>                        
                        </p:dataTable> 
                    </p:panel>
                    <p:panel header="Historico de Vendas" style="height: auto; width: auto" >  
                        <p:dataTable id="dataHistoricoTransacoesVendas"                                      
                                     scrollable="false"
                                     resizableColumns="false"
                                     paginator="true" 
                                     paginatorAlwaysVisible="false"                                      
                                     var="historicoVendas" 
                                     value="#{beanHistorico.getHistoricoVendas(beanLogin.usuarioLocal.pkId)}">
                            <p:column headerText="Comprador" style="text-align: center">
                                <h:outputText value="#{historicoVendas.comprador}"/>  
                            </p:column>
                            <p:column headerText="Vendedor" style="text-align: center">
                                <h:outputText value="#{historicoVendas.vendedor}"/>
                            </p:column>
                            <p:column headerText="Veiculo" style="text-align: center">
                                <h:outputText value="#{historicoVendas.veiculo}"/>
                            </p:column>
                            <p:column headerText="Valor" style="text-align: center">
                                <h:outputText value="#{historicoVendas.valor}"/>
                            </p:column>                        
                        </p:dataTable> 
                    </p:panel>
                </p:dialog>
            </div>
        </h:form>

        <!--Form minhas transaçoes -->        
        <h:form id="formTransacoesPendentes">
            <div align="center" >
                <p:dialog header="Minhas Transacões" id="diagTransacoes" widgetVar="diagTransacoes" >
                    <p:dataTable  
                        id="dataListTransacoes"                        
                        emptyMessage="Nenhuma transação pendente!"
                        var="transacoes" 
                        value="#{beanTransacoes.buscarTransacoes(beanLogin.usuarioLocal.pkId)}">                                                    
                        <p:column headerText=" Id Veiculo"  style="text-align: center">                            
                            <h:outputText value="#{transacoes.veiculos.pkVeiculos}"/>
                        </p:column>                      
                        <p:column headerText="Veiculo"  style="text-align: center">                            
                            <h:outputText value="#{transacoes.veiculos.nome}"/>
                        </p:column>                        
                        <p:column headerText="Comprador" style="text-align: center">                            
                            <h:outputText value="#{transacoes.usuariosByFkTransacoesComprador.apelido}"/>
                        </p:column>  
                        <p:column headerText="Finalizada" style="text-align: center">                            
                            <h:outputText value="#{transacoes.labelTerminada}"/>
                        </p:column>
                        <p:column headerText="Status">
                            <p:commandButton value="Concluir" 
                                             update=":formTransacoesPendentes:diagTransacoes"
                                             actionListener="#{beanTransacoes.concluirTransacoes(transacoes)}">
                                <p:confirm header="Confirmar Conclusão" message="Deseja Concluir a transação?" icon="ui-icon-alert"  />
                            </p:commandButton>
                            <p:commandButton value="Rejeitar"
                                             update=":formTransacoesPendentes:diagTransacoes"
                                             actionListener="#{beanTransacoes.cancelarTransacao(transacoes)}">
                                <p:confirm header="Confirmar Cancelar" message="Deseja cancelar a transação?" icon="ui-icon-alert"  />
                            </p:commandButton>
                        </p:column>
                        <p:confirmDialog global="true" showEffect="fade">  
                            <div align="center">
                                <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" update=":formPrincipal" />  
                                <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                            </div>
                        </p:confirmDialog>                                                
                    </p:dataTable>
                </p:dialog>
            </div> 
        </h:form>

        <!--form Comentarios -->
        <h:form id="formComentario">
            <p:dialog widgetVar="diagInserirComentarios" header="Comentar este veículo" >
                <div align="center">
                    <p:inputTextarea rows="5" 
                                     cols="30"                                          
                                     value="#{beanComentarios.comentario}"                                         
                                     maxlength="45"       
                                     counterTemplate="{0} caracteres restantes." autoResize="false">
                    </p:inputTextarea>                         

                    <div align="center">
                        <p:commandButton value="Inserir comentario"       
                                         oncomplete="PF('diagInserirComentarios').hide();"
                                         update=":formDiagVeiculos:outputDetalhesVeiculo"
                                         action="#{beanComentarios.inserirComentarios(beanVeiculo.veiculo, beanLogin.usuarioLocal)}">
                        </p:commandButton>
                    </div>
                </div>
            </p:dialog>
        </h:form>


    </h:body>
</html>
